package com.graduate.common.utils;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.Map;

/**
 * @author bwzfy
 * @create 2021/5/10
 **/
public class PageUtils {
    // 当前请求的页数
    public static final String PAGE = "pageNum";

    // 当前请求的每页的条数
    public static final String COUNT = "pageSize";

    // 当前需要查询的信息
    public static final String QUERY = "query";

    public static IPage<?> convertToPage(Map<String, Object> map) {
        String page = map.get(PAGE) == null? "1": (String) map.get(PAGE);
        String count = map.get(COUNT) == null? "8": (String) map.get(COUNT);
        return new Page<>(Integer.parseInt(page), Integer.parseInt(count));
    }
}
